package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Result struct {
	Message string      `json:"message"`
	Code    string      `json:"code"`
	Data    interface{} `json:"data"`
}

type PageResult struct {
	Total int64         `json:"total"`
	List  []interface{} `json:"list"`
}

func Success(data interface{}) *Result {
	return &Result{
		Code:    "00000",
		Message: "success",
		Data:    data,
	}
}

func Error(code string, message string) *Result {
	return &Result{
		Code:    code,
		Message: message,
	}
}

func (r *Result) JSON(c *gin.Context) {
	c.JSON(http.StatusOK, r)
}
